package com.wooophone.webapp.admin.web.util;


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;

public class FileUtil {
	  private static final int BUFFER_SIZE = 1024 * 1024 ;

	public static void copy(File oldFile, File targetFile) {
        try {
           InputStream in = null ;
           OutputStream out = null ;
            try {                
               in = new BufferedInputStream( new FileInputStream(oldFile),BUFFER_SIZE);
               out = new BufferedOutputStream( new FileOutputStream(targetFile),BUFFER_SIZE);
               byte [] buffer = new byte [BUFFER_SIZE];
               int length=0;
                while ((length=in.read(buffer)) > 0 ) {
                   out.write(buffer,0,length);
               } 
           } finally {
                if ( null != in) {
                   in.close();
               } 
                if ( null != out) {
                   out.close();
               } 
           } 
       } catch (Exception e) {
           e.printStackTrace();
       } 
   } 
	
}
